r"""
>>> from codeflow.planner.models import *
>>> from datetime import date

First, let's define some resources:

>>> # A simple shortcut to create resources:
>>> def resource(code_name, long_name):
...     return Resource.objects.create(code_name=code_name,
...                                    long_name=long_name)
... 
>>> abarberan = resource('abarberan', 'Antonio Barberan')
>>> fpainenao = resource('fpainenao', 'Freddy Painenao')
>>> imoyano = resource('imoyano', 'Ivan Moyano')
>>> lsoto = resource('lsoto', 'Leonardo Soto')
>>> mpinto = resource('mpinto', 'Mauricio Pinto')
>>> vsaavedra = resource('vsaavedra', 'Victor Saavedra')

Some vacations:

>>> # Yet another shortcut to make the code more readable
>>> def vacation(resource, start, end):
...     ResourceVacation.objects.create(resource=resource,
...                                     start=start, end=end)
...
>>> vacation(abarberan, date(2007, 2, 18), date(2007, 3, 12))
>>> vacation(imoyano, date(2007, 2, 12), date(2007, 3, 1))
>>> vacation(mpinto, date(2007, 3, 7), date(2010, 12, 31))

Check one of them:

>>> mpinto.resourcevacation_set.all()
[<ResourceVacation: Mauricio Pinto is on vacation from 2007-03-07 to 2010-12-31>]

Adjust the maximum hours per day of lsoto, available to planned work. This is
None by default, meaning that he works full time:

>>> lsoto.daily_max

>>> lsoto.daily_max = 3 # He tends to be busy doing management work.
>>> lsoto.save()
>>> lsoto.daily_max
3

Now here comes some projects:
>>> # Some more shortcuts:
>>> def project(start_date, root_task):
...     return Project.objects.create(start_date=start_date,
...                                   root_task=root_task)
...
>>> task = Task.objects.create
>>> # End of the shortcuts
>>> bci = resource('bci', 'BCI') 
>>> bci_incentivos_admin_docs = project(
...     date(2007, 2, 20),
...     task(code_name='bci_incentivos_admin_docs',
...          long_name='BCI: Incentivos: Administrador de Documentos',
...          priority=800))
>>> desarrollo = task(code_name='desarrollo',
...                   long_name='Desarrollo',
...                   effort_in_hours=28)
>>> bci_incentivos_admin_docs.root_task.task_set.add(desarrollo)
>>> desarrollo.allocation_set.add(Allocation(resource=fpainenao))



"""
if __name__ == "__main__":
    import doctest
    # import sys, os
    # os.environ['DJANGO_SETTINGS_MODULE'] = 'codeflow.planner'
    # sys.path.append('../../')
    doctest.testmod()

